<?php require('connections/con_gl.php'); ?>
<?php
cekAkses($_SESSION[akses],"A-2-2");
$colname_edit = "-1";
if (isset($_GET['id'])) {
  $colname_edit = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_con_gl, $con_gl);
$query_edit = sprintf("SELECT * FROM gl_budget WHERE id = %s", $colname_edit);
$edit = mysql_query($query_edit, $con_gl) or die(mysql_error());
$row_edit = mysql_fetch_assoc($edit);
$totalRows_edit = mysql_num_rows($edit);
// ---
mysql_select_db($database_con_gl, $con_gl);
$query_gudang = "SELECT id, gudang FROM gl_gudang";
if(!strstr($_SESSION[akses],'A-1-4')) {
	$query_gudang .= " where id='$_SESSION[lokasi]'";
}
$query_gudang .=" ORDER BY gudang ASC";
$gudang = mysql_query($query_gudang, $con_gl) or die(mysql_error());
$row_gudang = mysql_fetch_assoc($gudang);
$totalRows_gudang = mysql_num_rows($gudang);
?>
<link type="text/css" rel="stylesheet" href="css/jquery.wysiwyg.css" />
<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>
<link href="ccss/ui.datepicker.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="js/ui.datepicker.js"></script>
<script type="text/javascript">
<!--
$(function()
      {
        $('.calendar').datepicker({
            appendText : "",
            dateFormat : 'yy/mm/dd'
          });
      });
</script>
<script type="text/javascript">
$(document).ready(function() {

	$().ajaxStart(function() {
		$('#loading').show();
		$('#result').hide();
	}).ajaxStop(function() {
		$('#loading').hide();
		$('#result').fadeIn('slow');
	});

	$('#edit').submit(function() {
		$.ajax({
			type: 'POST',
			url: $(this).attr('action'),
			data: $(this).serialize(),
			success: function(data) {
				$('#result').html(data);
			}
		})
		return false;
	});
  $('#result').click(function(){
  $(this).hide();
  });
})
$(function()
  {
	  $('#keterangan').wysiwyg();
  });
</script>
<div id="loading" style="display:none;"><img src="images/loading.gif" alt="loading..." /></div>
<div id="result" style="display:none;"></div>
<h1>Edit Budgeting Kantor</h1>
<form action="proses/budgeting.php?act=edit" method="POST" name="edit" id="edit" >
  <table width="100%" border="0" align="center" cellpadding="5" cellspacing="0" class="datatable">
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Periode* :</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="mulai" type="text" class="calendar" id="mulai" value="<?php echo $row_edit['mulai'];?>" size="20" maxlength="15"/>
      </label>
        s/d
        <label>
          <input name="sampai" type="text" class="calendar" id="sampai" value="<?php echo $row_edit['sampai'];?>" size="20" maxlength="15"/>
        </label></td>
    </tr>
    <tr valign="top">
      <td width="20%" align="right" bgcolor="#FFFFFF">Lokasi Kantor* : </td>
      <td width="80%" bgcolor="#FFFFFF"><label>
        <select name="gudang" id="gudang">
          <option value="">Pilih Lokasi Kantor</option>
          <?php
do {  
?>
          <option value="<?php echo $row_gudang['id']?>" <?php if($row_gudang['id']==$row_edit['gudang']) { ?>selected="selected"<?php } ?>><?php echo $row_gudang['gudang']?></option>
          <?php
} while ($row_gudang = mysql_fetch_assoc($gudang));
  $rows = mysql_num_rows($gudang);
  if($rows > 0) {
      mysql_data_seek($gudang, 0);
	  $row_gudang = mysql_fetch_assoc($gudang);
  }
?>
        </select>
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Jumlah Budget* :</td>
      <td bgcolor="#FFFFFF"><label>
        <input name="budget" type="text" id="budget" value="<?php echo $row_edit['budget'];?>" size="10" maxlength="10" />
      </label></td>
    </tr>
    <tr valign="top">
      <td align="right" bgcolor="#FFFFFF">Keterangan : </td>
      <td bgcolor="#FFFFFF"><label>
        <textarea name="keterangan" cols="85" rows="5" id="keterangan"><?php echo $row_edit['info'];?></textarea>
        <input name="id" type="hidden" id="id" value="<?php echo $row_edit['id'];?>" />
      </label></td>
    </tr>
    <tr>
      <td align="left" bgcolor="#FFFFFF"><em>*Harus diisi</em></td>
      <td bgcolor="#FFFFFF"><label>
        <input name="Save" type="submit" id="Save" value="Simpan" />
      </label>
        <label>
          <input type="button" name="Button" value="Batal" onclick="javascript:history.go(-1);" />
        </label></td>
    </tr>
  </table>
</form>
